
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>管道流 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>管道流 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">Java中的管道流（Piped Streams）主要的应用场景是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">管道流主要用于实现两个线程之间的通信。</div>
          </div>
          <div class="card-source">来源: 文档开篇第一句</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">实现管道通信需要依赖哪两个核心的I/O类？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">实现管道通信需要依赖管道输出流 (PipedOutputStream) 和管道输入流 (PipedInputStream)。</div>
          </div>
          <div class="card-source">来源: 文档开篇第一句及代码示例</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">如何将一个 PipedOutputStream 和一个 PipedInputStream 连接起来以建立通信管道？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">通过在 PipedOutputStream 实例上调用其 connect(PipedInputStream snk) 方法，并将目标 PipedInputStream 实例作为参数传入，即可完成连接。</div>
          </div>
          <div class="card-source">来源: 文档中对 connect 方法的描述及代码示例的 `send.getPos().connect(recaive.getPis());` 部分</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">在提供的代码示例中，发送和接收逻辑是如何被组织起来以实现并发的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">发送逻辑被封装在实现了 Runnable 接口的 Send 类中，接收逻辑被封装在 Recelive 类中。主方法（main）为这两个 Runnable 实例分别创建并启动了新的 Thread 对象，从而使发送和接收操作并发执行。</div>
          </div>
          <div class="card-source">来源: 代码示例中的 Send、Recelive 类定义及 main 方法实现</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在示例代码的发送线程（Send）中，是如何将字符串数据写入管道流的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">发送线程首先将字符串 `"hello World"` 通过 `str.getBytes()` 方法转换为字节数组，然后调用 PipedOutputStream 的 `write()` 方法将该字节数组输出到管道中。</div>
          </div>
          <div class="card-source">来源: 代码示例中 Send 类的 run 方法</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">根据文档和代码，建立管道连接的操作（调用 connect 方法）应该在线程启动之前还是之后进行？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">建立管道连接的操作必须在相关线程启动之前进行。在代码示例中，`connect()` 方法的调用位于两个 `new Thread(...).start()` 语句之前。</div>
          </div>
          <div class="card-source">来源: 代码示例中的 main 方法逻辑顺序</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
